﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Javavaj.iHunter.Core
{

    /// <summary>
    /// 表示频道消息中含有的文件附件
    /// </summary>
    public class Attachment : IFileObject
    {
    
        public int Id
        {
            get;
            set;
        }

        /// <summary>
        /// 使用指定的文件名，类型，文件大小，文件引用路径以及描述创建文件对象
        /// </summary>
        /// <param name="filename">文件名</param>
        /// <param name="fileType">文件类型</param>
        /// <param name="fileSize">文件大小</param>
        /// <param name="fileUri">文件引用路径</param>
        /// <param name="description">文件描述</param>
        /// <remarks>
        /// 文件大小为用户指定的大小，该函数不会访问fileUrl去尝试获得真实大小
        /// fileUri可以为本地路径或远程路径
        /// </remarks>
        public Attachment(string filename, string fileType, long fileSize, string fileUri, string description)
        {
            Id = 0;
            this.Filename = filename;
            this.FileType = fileType;
            this.FileSize = fileSize;
            this.FileUri = fileUri;
            this.LocalPath = "";
            this.Description = (description == null ? "" : description);
        }

        public Attachment(int id, string filename, string fileType, long fileSize, string fileUri, string localPath, string description)
        {
            Id = id;
            this.Filename = filename;
            this.FileType = fileType;
            this.FileSize = fileSize;
            this.FileUri = fileUri;
            this.LocalPath = localPath;
            this.Description = (description == null ? "" : description);
        }

        /// <summary>
        /// 文件名
        /// </summary>
        public string Filename
        {
            get;
            set;
        }
        /// <summary>
        /// 文件类型 
        /// </summary>
        public string FileType
        {
            get;
            set;
        }

        /// <summary>
        /// 文件大小 
        /// </summary>
        public long FileSize
        {
            get;
            set;
        }

        /// <summary>
        /// 文件的下载链接 
        /// </summary>
        public string FileUri
        {
            get;
            set;
        }

        public string LocalPath
        {
            get;
            set;
        }
        /// <summary>
        /// 文件的简短描述
        /// </summary>
        public string Description
        {
            get;
            set;
        }

        public bool Equals(Attachment att)
        {
            return (this.Filename == att.Filename) && (this.FileSize == att.FileSize) && (this.FileUri == att.FileUri) && (this.Description == att.Description) && (this.FileType == att.FileType);
        }
    }
}
